home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / misc / Resource.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  1.6 KB  |  132 lines

  1. package sun.misc;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.InterruptedIOException;
  6. import java.net.URL;
  7. import java.nio.ByteBuffer;
  8. import java.security.CodeSigner;
  9. import java.security.cert.Certificate;
  10. import java.util.jar.Manifest;
  11. import sun.nio.ByteBuffered;
  12.  
  13. public abstract class Resource {
  14.    private InputStream cis;
  15.  
  16.    public abstract String getName();
  17.  
  18.    public abstract URL getURL();
  19.  
  20.    public abstract URL getCodeSourceURL();
  21.  
  22.    public abstract InputStream getInputStream() throws IOException;
  23.  
  24.    public abstract int getContentLength() throws IOException;
  25.  
  26.    private synchronized InputStream cachedInputStream() throws IOException {
  27.       if (this.cis == null) {
  28.          this.cis = this.getInputStream();
  29.       }
  30.  
  31.       return this.cis;
  32.    }
  33.  
  34.    public byte[] getBytes() throws IOException {
  35.       InputStream var2 = this.cachedInputStream();
  36.       boolean var3 = Thread.interrupted();
  37.  
  38.       int var4;
  39.       while(true) {
  40.          try {
  41.             var4 = this.getContentLength();
  42.             break;
  43.          } catch (InterruptedIOException var22) {
  44.             Thread.interrupted();
  45.             var3 = true;
  46.          }
  47.       }
  48.  
  49.       byte[] var1;
  50.       try {
  51.          int var5;
  52.          if (var4 != -1) {
  53.             for(var1 = new byte[var4]; var4 > 0; var4 -= var5) {
  54.                var5 = 0;
  55.  
  56.                try {
  57.                   var5 = var2.read(var1, var1.length - var4, var4);
  58.                } catch (InterruptedIOException var19) {
  59.                   Thread.interrupted();
  60.                   var3 = true;
  61.                }
  62.  
  63.                if (var5 == -1) {
  64.                   throw new IOException("unexpected EOF");
  65.                }
  66.             }
  67.          } else {
  68.             var1 = new byte[1024];
  69.             var5 = 0;
  70.  
  71.             while(true) {
  72.                var4 = 0;
  73.  
  74.                try {
  75.                   var4 = var2.read(var1, var5, var1.length - var5);
  76.                   if (var4 == -1) {
  77.                      break;
  78.                   }
  79.                } catch (InterruptedIOException var20) {
  80.                   Thread.interrupted();
  81.                   var3 = true;
  82.                }
  83.  
  84.                var5 += var4;
  85.                if (var5 >= var1.length) {
  86.                   byte[] var6 = new byte[var5 * 2];
  87.                   System.arraycopy(var1, 0, var6, 0, var5);
  88.                   var1 = var6;
  89.                }
  90.             }
  91.  
  92.             if (var5 != var1.length) {
  93.                byte[] var25 = new byte[var5];
  94.                System.arraycopy(var1, 0, var25, 0, var5);
  95.                var1 = var25;
  96.             }
  97.          }
  98.       } finally {
  99.          try {
  100.             var2.close();
  101.          } catch (InterruptedIOException var17) {
  102.             var3 = true;
  103.          } catch (IOException var18) {
  104.          }
  105.  
  106.          if (var3) {
  107.             Thread.currentThread().interrupt();
  108.          }
  109.  
  110.       }
  111.  
  112.       return var1;
  113.    }
  114.  
  115.    public ByteBuffer getByteBuffer() throws IOException {
  116.       InputStream var1 = this.cachedInputStream();
  117.       return var1 instanceof ByteBuffered ? ((ByteBuffered)var1).getByteBuffer() : null;
  118.    }
  119.  
  120.    public Manifest getManifest() throws IOException {
  121.       return null;
  122.    }
  123.  
  124.    public Certificate[] getCertificates() {
  125.       return null;
  126.    }
  127.  
  128.    public CodeSigner[] getCodeSigners() {
  129.       return null;
  130.    }
  131. }
  132.